<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title>第9节课第2次笔记</title>
		<style type="text/css">
			* {
				padding: 0;
				margin: 0;
			}

			.container {
				width: 100vw;
				height: 100vh;
				display: flex;
				/*
		     * 将边框设置在中间
		     */
				align-items: center;
				justify-content: center;
			}

			canvas {
				width: 500px;
				height: 500px;
				border: 1px solid #333333;
			}
		</style>
	<body>
		<!-- <img src="../img/img.png" id="img"> -->
		<div class="container">
			<canvas id="canvas" width="500px" height="500px"></canvas>
		</div>
	</body>
	<script>
		window.onload = function() {
			let yCanvas = document.getElementById('canvas');
			console.dir(yCanvas);
			let yPen = yCanvas.getContext("2d")

			// yPen.lineWidth=10;			
			// yPen.moveTo(100,100);
			// yPen.lineTo(100,200);
			// yPen.strokeStyle ="aqua";
			// yPen.stroke();

			// yPen.beginPath();
			// yPen.moveTo(100,100);
			// yPen.lineTo(100,200);
			// yPen.strokeStyle ="red";
			// yPen.stroke();

			// yPen.arc(100,100,50,0,Math.PI/180*90,false);
			// yPen.closePath();
			// yPen.stroke();

			// yPen.beginPath();
			// yPen.arc(200,200,50,0,Math.PI/180*90,false);
			// yPen.closePath();
			// yPen.stroke();


			//这个点的坐标如果在路上中，就返回true，否则就返回false
			//isPointInPath
			yPen.rect(50, 50, 80, 80);
			yPen.stroke();
			yPen.fill();

			if (yPen.isPointInPath(60, 60)) {
				alert('在路径中')
			} else {
				alert('不在路径中')
			}
		}
	</script>
</html>
